#!/bin/bash
#
#$ -cwd
#$ -j y
#$ -S /bin/bash
#

###############################################
###### IRIS-Processor #########################
###############################################

# This script processes an iris-database the following way
# Input Image 	=> Segmentation result (<filename>.png)
#		=> Iris code	       (<filename>.png)


if [ $# -ne 1 ]; then
	echo 'Call with parameters <DATAROOT>';
	echo '<DATAROOT> ... e.g. results/iitd';
	exit;
fi
 
 

DATAROOT=$1



# cd $DATAROOT;
# Find methods
METHODS=`ls -d $DATAROOT/method_*/`

ICTOOLS='qsw'


DISTTOOLS=($DISTTOOLS)

for method in $METHODS
do

  m=${method/$DATAROOT\//}
  
  
  echo "Eval method $m"

  for type in single double
  do
      TOOLS=`ls $method/$type`
      
      #echo $TOOLS;
      
      for tool in $TOOLS
      do
	  CRS=`ls $method/$type/$tool`
	   	  
	  for cr in $CRS
	  do
	       if [ "$type" = "single" ];
	       then
		qualis='/'
	      else
		  qualis=`ls $method/$type/$tool/$cr`
	      fi
	    #  echo $qualis;
	      
	      for qual in $qualis
	      do
		  idx=0
		  
		  DISTFILES=`ls  $method/$type/$tool/$cr/$qual/ic/ | grep .dist.csv`
		  
		  
		  for dist in $DISTFILES
		  do
		  
		  INFILE="$method/$type/$tool/$cr/$qual/ic/$dist"
		  if [ "$type" = "single" ];
		  then
		     OUTFILE=$method/$type/$tool/${dist/.dist/.eer}
		  else
		     OUTFILE=$method/$type/$tool/${dist/.dist/.$qual.eer}
		  fi
		   
		  
		   echo "Compute EER for $INFILE with label $cr to $OUTFILE"
		   #java -jar agingEval.jar $INFILE $cr $OUTFILE
		    
		    
		  done
	      done
	      
	      
	  done
	  
	  
	  
	  
	  
      done
  
  done
  

  
  
 
  
  
  
  

done
